package com.anji.tug;

public class Objective {
		
	public Objective(float finalGoal /*, boolean isInverseObjective */, float recencyAlpha, float goalUpdateEta) {
		this.recencyAlpha = recencyAlpha;
		this.goalUpdateEta = goalUpdateEta;
		isOn = true;
		goal = 0;
		this.finalGoal = finalGoal;
		record = 0;
		recencyAvg = 0;
		avg = 0;
//			this.isInverseObjective = isInverseObjective;
	}
	
	public Objective(float finalGoal, float recencyAlpha, float goalUpdateEta, String name) {
		this.recencyAlpha = recencyAlpha;
		this.goalUpdateEta = goalUpdateEta;
		isOn = true;
		goal = 0;
		this.finalGoal = finalGoal;
		record = 0;
		recencyAvg = 0;
		avg = 0;
		this.name = name;
	}

	protected float recencyAlpha;	// Parameter controlling recency average
	protected float goalUpdateEta;	// Parameter controlling goal growth
	
	public boolean isOn;
	public float goal;
	public float finalGoal;
	public float record;
	public float recencyAvg;
	public float avg;
	public String name;
	
	public void updateRecencyAverage() {
		recencyAvg += recencyAlpha * (avg - recencyAvg);
	}
	
	public void updateGoal() {
		goal += goalUpdateEta * (record - goal);
		if (goal > finalGoal) goal = finalGoal;
		isOn = true;
		recencyAvg = 0.0f;
	}
		
}
